<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of v_dlyapsq</title>
  <meta name="keywords" content="v_dlyapsq">
  <meta name="description" content="V_DLYAPSQ Solves the discrete Lyapunov equation AV'VA' - V'V + BB' = 0">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt;  <a href="index.html">v_mfiles</a> &gt; v_dlyapsq.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for v_mfiles&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->

<h1>v_dlyapsq
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>V_DLYAPSQ Solves the discrete Lyapunov equation AV'VA' - V'V + BB' = 0</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function v=v_dlyapsq(a,b) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment">V_DLYAPSQ Solves the discrete Lyapunov equation AV'VA' - V'V + BB' = 0
 V is upper triangular with real non-negative diagonal entries
 this is equivalent to v=chol(dlyap(a,b*b')) but better conditioned numerically</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function v=v_dlyapsq(a,b)</a>
0002 <span class="comment">%V_DLYAPSQ Solves the discrete Lyapunov equation AV'VA' - V'V + BB' = 0</span>
0003 <span class="comment">% V is upper triangular with real non-negative diagonal entries</span>
0004 <span class="comment">% this is equivalent to v=chol(dlyap(a,b*b')) but better conditioned numerically</span>
0005 
0006 <span class="comment">%      Copyright (C) Mike Brookes 2002</span>
0007 <span class="comment">%      Version: $Id: v_dlyapsq.m 10865 2018-09-21 17:22:45Z dmb $</span>
0008 <span class="comment">%</span>
0009 <span class="comment">%   VOICEBOX is a MATLAB toolbox for speech processing.</span>
0010 <span class="comment">%   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html</span>
0011 <span class="comment">%</span>
0012 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>
0013 <span class="comment">%   This program is free software; you can redistribute it and/or modify</span>
0014 <span class="comment">%   it under the terms of the GNU General Public License as published by</span>
0015 <span class="comment">%   the Free Software Foundation; either version 2 of the License, or</span>
0016 <span class="comment">%   (at your option) any later version.</span>
0017 <span class="comment">%</span>
0018 <span class="comment">%   This program is distributed in the hope that it will be useful,</span>
0019 <span class="comment">%   but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
0020 <span class="comment">%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
0021 <span class="comment">%   GNU General Public License for more details.</span>
0022 <span class="comment">%</span>
0023 <span class="comment">%   You can obtain a copy of the GNU General Public License from</span>
0024 <span class="comment">%   http://www.gnu.org/copyleft/gpl.html or by writing to</span>
0025 <span class="comment">%   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.</span>
0026 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>
0027 
0028 [q,s]=schur(a');
0029 [q,s]=rsf2csf(q,s);
0030 [qd,r]=qr(b'*q,0);
0031 <span class="comment">% save r for testing</span>
0032 r0=r;
0033 [m,n]=size(r);
0034 u=zeros(n,n);
0035 <span class="keyword">if</span> m==1
0036    <span class="keyword">for</span> i=1:n-1
0037       in=i+1:n;
0038       si=s(i,i);
0039       aa=sqrt(1-si*si');
0040       u(i,i)=r(1)/aa;
0041       u(i,in)=(u(i,i)*si'*s(i,in)+aa*r(2:end))/(eye(n-i)-si'*s(in,in));
0042       r=aa*(u(i,i)*s(i,in)+u(i,in)*s(in,in))-si*r(2:end);
0043    <span class="keyword">end</span>
0044    u(n,n)=r/sqrt(1-s(n,n)*s(n,n)');
0045    
0046 <span class="keyword">else</span>
0047    w=zeros(m,1); w(m)=1;
0048    em=eye(m);
0049    <span class="keyword">for</span> i=1:n-m
0050       in=i+1:n;
0051       si=s(i,i);
0052       aa=sqrt(1-si*si');
0053       u(i,i)=r(1,1)/aa;
0054       u(i,in)=(u(i,i)*si'*s(i,in)+aa*r(1,2:end))/(eye(n-i)-si'*s(in,in));
0055       vv=aa*(u(i,i)*s(i,in)+u(i,in)*s(in,in))-si*r(1,2:end);
0056       rr=zeros(m,n-i);
0057       rr(1:m-1,:)=r(2:<span class="keyword">end</span>,2:end);
0058       [qq,r]=qrupdate(em,rr,w,vv');
0059    <span class="keyword">end</span>
0060    <span class="keyword">for</span> i=n-m+1:n-1
0061       in=i+1:n;
0062       si=s(i,i);
0063       aa=sqrt(1-si*si');
0064       u(i,i)=r(1,1)/aa;
0065       u(i,in)=(u(i,i)*si'*s(i,in)+aa*r(1,2:end))/(eye(n-i)-si'*s(in,in));
0066       vv=aa*(u(i,i)*s(i,in)+u(i,in)*s(in,in))-si*r(1,2:end);
0067       rr=zeros(n-i+1,n-i);
0068       rr(1:n-i,:)=r(2:<span class="keyword">end</span>,2:end);
0069       [qq,rr]=qrupdate(eye(n-i+1),rr,w(m-n+i:end),vv');
0070       r=rr(1:n-i,:);
0071    <span class="keyword">end</span>
0072    
0073    u(n,n)=r/sqrt(1-s(n,n)*s(n,n)');
0074    
0075 <span class="keyword">end</span>
0076 
0077 v=triu(qr(u*q'));
0078 dv=diag(v);
0079 ix=dv~=0;
0080 v(ix,:)=diag(abs(dv(ix))./dv(ix))*v(ix,:);
0081 <span class="keyword">if</span> isreal(a) &amp; isreal(b)
0082    v=real(v);
0083 <span class="keyword">end</span></pre></div>
<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>